Auto Scaling Group (ASG)
💡 Definition
An Auto Scaling Group (ASG) is a collection of EC2 instances that are treated as a logical unit for the purposes of automatic scaling and management. It is the core component of Amazon Auto Scaling.
🔑 Key Concepts
- Capacity Settings:
- Minimum: The fewest number of instances the group should ever have.
- Maximum: The most instances the group is allowed to scale out to.
- Desired: The target number of instances you want running right now.
- Self-Healing: If an instance becomes unhealthy (fails a health check), the ASG terminates it and launches a new one to maintain the Desired/Minimum capacity.
- Scaling Policies: Rules that tell the ASG when to launch (scale out) or terminate (scale in) instances based on metrics like CPU utilization.
⚙️ How it Works
- Define: You create an ASG, specifying the Launch Template and the VPC subnets.
- Monitor: The ASG monitors the health of instances.
- Scale: Based on alarms or schedules, it changes the Desired Capacity.
- Launch/Terminate: It calls the EC2 API to launch or terminate instances to match the Desired Capacity.
🎯 Use Cases
- Dynamic Workloads: Applications with traffic that varies throughout the day.
- High Availability: Ensuring at least X instances are always running across multiple AZs.
- Fleet Management: Automatically replacing failed hardware.
💰 Pricing Model
- Free: The ASG feature itself is free. You pay for the EC2 instances it runs.
📝 Exam Tips (CLF-C02)
- Defines WHERE (VPC/Subnets) and HOW MANY (Min/Max/Desired) instances to run.
- Uses a Launch Template to define WHAT to run.
- Can span multiple Availability Zones.
See Also: * Launch Template * Load Balancer * Auto Scaling